import React from 'react';
import {Select} from 'antd';
const Option = Select.Option;
export default {
    formateDate(time) {
        if (!time) return '';
        let date = new Date(time)
        return date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':'+date.getSeconds();
    },
    pagination(data, callback) {
        let page = {
            onChange: (current) => {
                callback(current)
            },
            current: data.result.page,
            pageSize: data.result.pageSize,
            total: data.result.totalCount,
            showTotal: () => {
                return `共${data.result.totalCount}条`
            },
            showQuickJumper: true,        // 是否可以快速跳转至某页
            // showSizeChanger: true         // 是否可以改变pageSize
        }
        return page;
    },
    getOptionList(data) {
        if(!data){
            return [];
        }
        let options = [] //[<Option value="0" key="all_key">全部</Option>];
        data.map((item)=>{
            options.push(<Option value={item.id} key={item.id}>{item.name}</Option>)
        })
        return options;
    }
}